<?php

namespace App\Models\Manage;

use App\Models\BaseModel;
use App\Models\ManageAdminModel;

class LogsAdminModel extends BaseModel
{
    protected $table = 'logs_admin';

    protected $primaryKey = 'id';

    protected $guarded = [];

    public $dateFormat = 'U';

    private $operatorTitle;

    private $remark;

    private $optData;

    public function setOptTitle($title)
    {
        $this->operatorTitle = $title;
        return $this;
    }

    public function setRemark($remark)
    {
        $this->remark = $remark;
        return $this;
    }

    public function setOptData($data)
    {
        $this->optData = json_encode($data);
        return $this;
    }

    public function recording($type=3)
    {
        $data['operator_id']=ManageAdminModel::init()->getLoginId();
        $data['operate_type']=$type;
        $data['operator_title']=$this->operatorTitle;
        $data['operate_data'] = $this->optData;
        $data['remark']=$this->remark;
        $data['operator_ip']=get_client_ip(1);
        return self::create($data);
    }
}
